package day0723;

import java.util.Scanner;

public class Test8 {
    public static void main(String[] args) {
        //1.定义一个数组，存储一组数字
        int[] a={5, 12, 21, 23, 34, 34, 67, 743};
        //2.输入一个需要查找的元素

        int findEle=670;


        //3.从a数组中查找findEle元素的所在位置(存入到positionIndex中)
        int left=0;
        int right=a.length-1;
        for(;left<=right;){
            int middle=(left+right+1)/2;
            if(findEle==a[middle]){
                System.out.println(middle);
                break;
            }else if(findEle>a[middle]){
                left = middle+1;
            }else{
                right=middle-1;
            }
        }//4.打印存储的positionIndex中的序号


    }
}
